from matplotlib import pyplot as plt
import math
# serial = [0.0, 0.0, 0.0001, 0.0003, 0.0012, 0.0065, 0.0462, 0.3722, 2.9774, 47.3015, 185.423, 1861.14, 15386.7, 121714.0]
# sse = [0.0001, 0.0001, 0.0002, 0.0004, 0.0011, 0.0036, 0.02, 0.1189, 0.7887, 11.4794, 54.095, 756.465, 8779.29, 69063.0]
# avx = [0.0, 0.0, 0.0002, 0.0006, 0.0017, 0.0061, 0.0258, 0.1394, 0.6955, 5.2371, 39.2855, 687.175, 7695.22, 60468.5]
# sse_align = [0.0, 0.0, 0.0002, 0.0006, 0.0017, 0.0048, 0.0196, 0.1135, 0.8142, 8.4552, 53.8023, 753.866, 7737.88, 63289.8]

# data = [[0.0, 0.0001, 0.0001, 0.0004, 0.0015, 0.0085, 0.0559, 0.4274, 3.3515, 27.7308, 228.519, 2152.63, 17014.1, 133241.0], [0.5213, 0.8566, 3.111, 3.2002, 6.0242, 14.0636, 23.2099, 39.265, 76.5468, 170.136, 486.773, 2002.52, 11562.3, 78292.9], [0.3212, 0.5941, 1.3693, 2.4263, 5.0073, 9.9972, 17.0699, 32.584, 71.0256, 160.598, 410.968, 1593.84, 9879.78, 70674.6]]
# data = [[0.3212, 0.5941, 1.3693, 2.4263, 5.0073, 9.9972, 17.0699, 32.584, 71.0256, 160.598, 410.968, 1593.84, 9879.78, 70674.6],[0.1561, 0.2165, 0.2252, 0.262, 0.4046, 1.0963, 1.3147, 4.3597, 8.3717, 24.0138, 168.991, 1124.77, 10121.6, 77705.9]]
# col_pool
# data = [[0.216, 0.233, 0.2932, 0.3757, 0.2841, 0.5236, 2.9077, 4.6643, 9.8155, 54.7564, 194.951, 1626.75, 11656.2, 86677.2]]

# serial
# data = [[0.0, 0.0001, 0.0001, 0.0004, 0.0015, 0.0085, 0.0559, 0.4274, 3.3515, 27.7308, 228.519, 2152.63, 17014.1, 133241.0]]

# pthread col, row, row_sse
# data = [[0.3212, 0.5941, 1.3693, 2.4263, 5.0073, 9.9972, 17.0699, 32.584, 71.0256, 160.598, 410.968, 1593.84, 9879.78, 70674.6], [0.5213, 0.8566, 3.111, 3.2002, 6.0242, 14.0636, 23.2099, 39.265, 76.5468, 170.136, 486.773, 2002.52, 11562.3, 78292.9], [0.6468, 1.0334, 1.7286, 3.9825, 7.1448, 17.7213, 20.8026, 46.363, 99.18, 145.73, 386.208, 1297.77, 8257.74, 59520.0]]

# openmp row, col, row_sse
# data = [[0.7616, 0.8376, 1.3622, 1.685, 2.0353, 2.9188, 3.4943, 7.7875, 13.8055, 39.9751, 193.184, 1098.85, 13183.6, 81395.3], [0.2377, 0.4996, 0.7548, 0.688, 1.464, 1.1486, 2.5121, 5.5698, 12.5275, 44.2463, 282.564, 1264.51, 13217.7, 84437.1], [0.2403, 0.2299, 0.5722, 0.376, 0.7667, 1.1287, 2.2368, 5.3143, 11.1006, 27.8285, 96.2555, 865.296, 9181.64, 68696.8]]

data = [[
    0.0, 0.0001, 0.0001, 0.0004, 0.0015, 0.0085, 0.0559, 0.4274, 3.3515,
    27.7308, 228.519, 2152.63, 17014.1, 133241.0
],
        [
            0.2403, 0.2299, 0.5722, 0.376, 0.7667, 1.1287, 2.2368, 5.3143,
            11.1006, 27.8285, 96.2555, 865.296, 9181.64, 68696.8
        ],
        [
            0.6468, 1.0334, 1.7286, 3.9825, 7.1448, 17.7213, 20.8026, 46.363,
            99.18, 145.73, 386.208, 1297.77, 8257.74, 59520.0
        ]]

# logserial = [math.log2(i) for i in serial[-5:]]
# logsse = [math.log2(i) for i in sse[-5:]]
# logsse_align = [math.log2(i) for i in sse_align[-5:]]
# logavx = [math.log2(i) for i in avx[-5:]]

# logdata = []
# for ls in data:
#     logdata.append([math.log2(i) for i in ls[-5:]])

# print(logdata)

# print(len(sse))

# time = [10,11,12,13,14]
time = [i for i in range(14)]
# time = [i for i in range(7)]
# print(len(time))
# print(len(data[0]))
# print(len(data[1]))
# plt.plot(time, serial, 'r--', label='serial')
# plt.plot(time, sse[:6], 'r--', label='SSE')
# plt.plot(time, sse_align[:6], 'b--', label='SSE align')

# plt.plot(time, data[0][:7], 'r--', label='serial')
# plt.plot(time, data[1][:7], 'g--', label='openmp col')
# plt.plot(time, data[2][:7], 'b--', label='pthread col')

plt.plot(time, data[0][:14], 'r--', label='serial')
plt.plot(time, data[1][:14], 'g--', label='openmp row_sse')
plt.plot(time, data[2][:14], 'b--', label='pthread row_sse')

# plt.plot(time, logserial, 'r--', label='serial')
# plt.plot(time, logsse, 'r--', label='SSE')
# plt.plot(time, logsse_align, 'b--', label='SSE_align')

# plt.plot(time, logdata[0], 'r--', label='serial')
# plt.plot(time, logdata[1], 'g--', label='openmp row_sse')
# plt.plot(time, logdata[2], 'b--', label='pthread row_sse')
# plt.plot(time, logdata[3], 'c--', label='SSE')

plt.xlabel("log N")
plt.ylabel("time/ms")
plt.legend()
plt.savefig('E:\\大二下\\并行程序设计\\实验\\实验4\\result10.pdf')
plt.show()